async function login(dataBox) {
  try {
    let res = await axios({
      url: '/login',
      method: "POST",
      data: dataBox
    })
    console.log(res.data);
    let {username,token} = res.data.data
    localStorage.setItem('username',username)
    localStorage.setItem('token',token)
    pxmu.success('登录成功');
    location.href = './index.html'

  } catch (err) {
    pxmu.fail(err.response.data.message || '登录失败，请检查网络请求')
  }
}

document.querySelector('#btn-login').addEventListener('click', function (e) {
  e.preventDefault()
  let form = document.querySelector('.login-form')
  let body = serialize(form,{hash:true,empty:true})
  let {username , password} = body
  if(!validatData(username,password)){
    pxmu.fail('【用户名】或者【密码】不符合规范')
    return
  }
  login(body)
})